package com.laivi.basic.model.datastruct;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @author laivi.zhu@gmail.com
 * @date 2014-6-16
 * description:
 */
public class Queue<T> implements Collection<T>{
	private List<T> queue;
	
	private int size;

	public Queue(int size) {
		super();
		this.size = size;
		queue=new LinkedList<T>();
	}

	public Queue() {
		super();
	}
	
	public void enQueue(T t){
		if(queue.size()>=size && size!=0){
			this.deQueue();
		}
		queue.add(t);
	}
	
	public void enQueue(T t,boolean isFront){
		
	}
	
	public T deQueue(){
		if(queue.size()>0){
			return queue.remove(0);
		}
		return null;
	}
	
	public boolean isEmpty(){
		return queue.size()==0;
	}
	
	public boolean contians(T t){
		return queue.contains(t);
	}

	public void setSize(int size) {
		this.size = size;
	}
	
	public T getFirst(){
		return null;
	}
	
	public T getLast(){
		return null;
	}
	
	public List<T> getQueue(){
		return null;
	}

	@Override
	public int size() {
		return queue.size();
	}

	@Override
	public boolean contains(Object o) {
		return queue.contains(o);
	}

	@Override
	public Iterator<T> iterator() {
		return queue.iterator();
	}

	@Override
	public Object[] toArray() {
		return queue.toArray();
	}

	@SuppressWarnings("hiding")
	@Override
	public <T> T[] toArray(T[] a) {
		return queue.toArray(a);
	}

	@Override
	public boolean add(T e) {
		return queue.add(e);
	}

	@Override
	public boolean remove(Object o) {
		return queue.remove(o);
	}

	@Override
	public boolean containsAll(Collection<?> c) {
		return queue.containsAll(c);
	}

	@Override
	public boolean addAll(Collection<? extends T> c) {
		return queue.addAll(c);
	}

	@Override
	public boolean removeAll(Collection<?> c) {
		return queue.removeAll(c);
	}

	@Override
	public boolean retainAll(Collection<?> c) {
		return queue.retainAll(c);
	}

	@Override
	public void clear() {
		queue.clear();
	}
}
